<?php 
$sql_slider = "SELECT * FROM `anuncios`,`imagens_anuncio` WHERE `anuncios`.`id_anuncio` LIKE `imagens_anuncio`.`anuncio_id` AND `imagens_anuncio`.`foto_pos` LIKE '0'";

$result_slider = mysql_query($sql_slider);
$total = mysql_num_rows($result_slider);
if($total>4){
	

	
?>

<div class="well well-small">
			<h4>Featured Products <small class="pull-right">200+ featured products</small></h4>
			<div class="row-fluid">
			<div id="featured" class="carousel slide">
			<div class="carousel-inner">
			  <div class="item active">
			  <ul class="thumbnails">
				<li class="span3">
				  <div class="thumbnail">
				  <i class="caption"></i>
					<a href="product_details.html"><img style="width: 160px; height: 140px" src="img/holandaDesign.jpg" alt=""></a>
					<div class="caption">
					  <h5>Holanda Design</h5>
					  <h4><a class="btn" href="product_details.html">VIEW</a></h4>
					</div>
				  </div>
				</li>
				<?php 
				for($i=0;$i<3;$i++){ ?>
					<li class="span3">
					  <div class="thumbnail">
					  <i class="caption"></i>
						<a href="product_details.html"><img src="http://placehold.it/160x140" alt=""></a>
						<div class="caption">
						  <h5>Product name</h5>
						  <h4><a class="btn" href="product_details.html">VIEW</a></h4>
						</div>
					  </div>
					</li>
				
			<?php }
				?>
			  </ul>
			  </div>
			  
			  <?php
			  
			  $mode = 1;
			  for($j=0;$j<$mode;$j++){
				$row=mysql_fetch_array($result_slider);
				$id = $row['id_anuncio'];
				$foto_url = $row['foto_url'];
				$preco = $row['preco'];
				$tipo = $row['tipo_anuncio_id'];
				if($tipo==1){
					$tipo_anuncio = "Vende-se";
				}
				if($tipo == 2){
					$tipo_anuncio = "Compra-se";
				}
				if($tipo==3){
					$tipo_anuncio = "Aluga-se";
				}
					
				//$mode = $total/4;
				echo $mode;
				
				echo "<div class='item'>
			  			<ul class='thumbnails'>";  
				for($i=0;$i<4;$i++){?>
				  	
				  <li class="span3">
					  <div class="thumbnail">
					  <i class="tag"></i>
						<a href="index.php?pg=ver-produto&id=<?php echo $id; ?>"><img src="admin/<?php echo $foto_url; ?>" alt=""></a>
						<div class="caption">
						  <h5><?php echo $tipo_anuncio; ?></h5>
						  <h4><a class="btn" href="product_details.html">VIEW</a> <span class="pull-right">R$ <?php echo $preco; ?> </span></h4>
						</div>
					  </div>
					</li>
				  
			<?php 
			$sql_slider = "SELECT * FROM `anuncios`,`imagens_anuncio` WHERE `anuncios`.`id_anuncio` LIKE `imagens_anuncio`.`anuncio_id` AND `imagens_anuncio`.`foto_pos` LIKE '0' AND `anuncios`.`id_anuncio` <> $id";
			
			$result_slider = mysql_query($sql_slider);
			$row=mysql_fetch_array($result_slider);
			$id = $row['id_anuncio'];
			$foto_url = $row['foto_url'];
			$preco = $row['preco'];
			$tipo = $row['tipo_anuncio_id'];
				}
				  echo "</ul> </div>";
				
			  }
			  ?>
			  
			  </div>
			  <a class="left carousel-control" href="#featured" data-slide="prev">&lsaquo;</a>
			  <a class="right carousel-control" href="#featured" data-slide="next">&rsaquo;</a>
			  </div>
			  </div>
		</div>
	
	<?php 
}	
?>